<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const p1 = new Promise((resolve, reject) => {
      try {
        console.log("请求数据A")
        // throw new Error("A错误")
        setTimeout(() => {
          console.log("请求A结束....");
          resolve("A数据")
        }, 1500)
      } catch (e) {
        reject(e.message)
      }
    })

    const p2 = new Promise((resolve, reject) => {
      try {
        console.log("请求数据B")
        // throw new Error("B错误")
        setTimeout(() => {
          console.log("请求B结束....");
          resolve("B数据")
        }, 2500)
      } catch (e) {
        reject(e.message)
      }
    })


    const p3 = new Promise((resolve, reject) => {
      try {
        console.log("请求数据C")
        throw new Error("C错误")
        setTimeout(() => {
          console.log("请求C结束....");
          resolve("C数据")
        }, 2000)
      } catch (e) {
        reject(e.message)
      }
    })
   const a1 = Promise.all([p1,p2,p3])
   console.log(a1)  
    /*
        all方法：是promise的静态方法
        接收一个数组(原则上是iterable类型)作为参数，数组里放promise的实例对象
        all的返回值：1.默认为pending状态的promise实例
        2.当传入的promise实例全部完成，返回成功状态的promise实例，值为一个数组，数组中每一项是传入的成功promise实例的值
        3.当传入的promise实例有一个为失败状态，直接返回失败状态的promise实例，值为失败promise实例的值
    */   
    </script>
</body>
</html>